package org.lanqiao.api.order;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.common.Constants;
import org.lanqiao.common.JsonResult;
import org.lanqiao.common.JsonResultWriter;
import org.lanqiao.service.OrderServiceImpl;

/**
 * 修改订单
 * 
 */
@WebServlet("/api/order/AmendOrder")
public class AmendOrder extends HttpServlet {
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		/**
		 * 获取参数
		 */
			String id=request.getParameter("orderId");		
			String price=request.getParameter("orderprice");
		    String userId=request.getParameter("userId");
		    String number="10";
			String page=request.getParameter("page");
			/**
			 * 调用修改订单方法
			 */
			OrderServiceImpl  abc = new OrderServiceImpl();
			JsonResult result=null;
			try {
				List list=abc.amendOrders(price, id, userId);
				if(list.size()>0){
					result=new JsonResult("修改成功",Constants.STATUS_SUCCESS,list);
				}else {
					result=new JsonResult("修改错误",Constants.STATUS_UNFOUND);
				}
			} catch (Exception e) {
				result=new JsonResult("修改异常",Constants.STATUS_FAILURE);
			}
			JsonResultWriter.writer(response, result);;
	}

}
